﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Sands.Common;
using Sands.DataAccess;
using Sands.Web;
using Sands.Web.Install;
using SAWeb.Model;

namespace SAWeb.Web.Install
{
    public partial class InstallMySql : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lbtnCreateConn_Click(object sender, EventArgs e)
        {
            MySqlInstallHelper.CreateConn(txtServer.Text.Trim(), txtDataBase.Text.Trim(), txtUid.Text.Trim(), txtPwd.Text.Trim(), txtPort.Text.Trim(), cbCreateDb.Checked);
        }

        protected void lbtnSave_Click(object sender, EventArgs e)
        {
            MySqlInstallHelper.CreateDataBase("/Install/crebas.sql");
        }

        protected void InitData(DataContext db)
        {
            //账户
            Model.Users admin = new Model.Users()
            {
                UserCode = "admin",
                Password = "admin".Encrypt(),
                Name = "Admin",
                Role = 1
            };
            admin.Save(db);

            //模块初始化


        }
    }
}